import config from "@/config"
import http from "@/utils/request"



export default {
  getTaskList: {
    url: `${config.API_URL}/quartzJob/list`,
    name: "获取定时任务列表",
    get: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  addTask: {
    url: `${config.API_URL}/quartzJob/add`,
    name: "添加定时任务",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  updateTask: {
    url: `${config.API_URL}/quartzJob/update`,
    name: "修改定时任务",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  deleteTask: {
    url: `${config.API_URL}/quartzJob/delete`,
    name: "删除定时任务",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  pauseTask: {
    url: `${config.API_URL}/quartzJob/pause`,
    name: "暂停定时任务",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  resumeTask: {
    url: `${config.API_URL}/quartzJob/resume`,
    name: "恢复定时任务",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
}
